//public variable that have assigned the GUI class
var playerUp: GUI;
var playerDown: GUI;
var playerJump: GUI;
var myplayer: GameObject;

//applying the custom skin
function OnGUI () 
{
	//initializing
	//myplayer = GameObject.Find("player");
	//Debug.Log(myplayer.name);
	if(myplayer)
	{
		InitApp();
	}
	
}

function InitApp()
{	
	//adding events
	if(playerUp.Button(Rect(Screen.width - 90, 10, 80, 40), "UP"))
	{
		UpEventHandler();
		//Debug.Log(playerUp.Button(Rect(Screen.width - 90, 10, 80, 40), "UP"));
	}
	
	if(playerDown.Button(Rect(Screen.width - 90, Screen.height - 50, 80, 40), "DOWN"))
	{
		DownEventHandler();
	}
	
	if(playerJump.Button(Rect(Screen.width - 90, Screen.height/2 - 20, 80, 40), "JUMP"))
	{
		JumpEventHandler();
	}
}

function UpEventHandler()
{
	var upTranslation: float = 50;
	//myplayer.transform.Translate(0, 0, upTranslation);
	myplayer.rigidbody.AddForce(0, 0, 1*upTranslation);
	//myplayer.rigidbody.position.z += upTranslation;
	myplayer.rigidbody.freezeRotation = true;
}

function DownEventHandler()
{
	var downTranslation: float = -50;
	//myplayer.transform.Translate(0, 0, downTranslation);
	myplayer.rigidbody.AddForce(0, 0, 1*downTranslation);
	myplayer.rigidbody.freezeRotation = true;
}

function JumpEventHandler()
{
	var jump: float = 200;
	
	myplayer.rigidbody.AddForce(0, 1*jump, 0);
	
	//myplayer.rigidbody.angularVelocity = Vector3(0, 0, 0);
}

